﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using AimGameEngine.EditorObject;

using AimGameLibrary;

namespace AimGameEngine.NodeEditorObject
{
    public class NodeCollision : NodeBaseControl
    {
        protected String NameBody1 = "NULL";
        protected String NameBody2 = "NULL";

        public NodeCollision(SpriteBatch inputspritebatch, Camera inputcamera, NodeData inputData
            , List<IDraw> MyListDraw, List<IUpdateMainTime> MyListUpdateTime, Dictionary<String, NodeObject> MyListObject, Dictionary<String, NodeObject> MyListType)
            : base(inputspritebatch, inputcamera, inputData, MyListDraw,MyListUpdateTime, MyListObject, MyListType)
	    {

            Connecter outputBoolean = new Connecter(inputspritebatch, inputcamera, Syco.Output, NodeTypeValue.Boolean, this);
            ListConnectpoint.Add(outputBoolean);

            Connecter outputUpdate = new Connecter(inputspritebatch, inputcamera, Syco.Output, NodeTypeValue.Update, this);
            ListConnectpoint.Add(outputUpdate);

            Connecter inputBody1 = new Connecter(inputspritebatch, inputcamera, Syco.Input, NodeTypeValue.Body, this);
            ListConnectpoint.Add(inputBody1);

            Connecter inputBody2 = new Connecter(inputspritebatch, inputcamera, Syco.Input, NodeTypeValue.Body, this);
            ListConnectpoint.Add(inputBody2);
	    }

        public override void SetupInput(Connecter Thisconnect, Connecter connectOutput)
        {
            switch (ListConnectpointInput.IndexOf(Thisconnect))
            {
                case 0: NameBody1 = connectOutput.MyNode.MyData.MyName; break;
                case 1: NameBody2 = connectOutput.MyNode.MyData.MyName; break;
            }
            MyData.Data = NameBody1 + "|" + NameBody2;
        }

        public override void ClearInput(Connecter ThisInputConnect, Connecter ThisConnectClear, string NameThisClear)
        {
            //base.ClearInput(ThisConnectClear, NameThisClear);
            MyData.Data = MyData.Data.Replace(NameThisClear, "NULL");
        }

        protected override Dictionary<string, NodeObject> GetDictionaryNode(Dictionary<string, NodeObject> TempNode)
        {
            if(NameBody1 != null)
            if (this.MyDictionaryObject.ContainsKey(NameBody1))
                TempNode.Add(NameBody1, this.MyDictionaryObject[NameBody1]);

            if (NameBody2 != null)
            if (this.MyDictionaryObject.ContainsKey(NameBody2))
                TempNode.Add(NameBody2, this.MyDictionaryObject[NameBody2]);

            return base.GetDictionaryNode(TempNode);
        }
    }
}
